package com.xls.boxlibrary.dilog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xls.boxlibrary.R;

import java.util.Timer;
import java.util.TimerTask;

public class OkDialog extends Dialog {

    private TextView dialog_text;
    String hint="";
    private TextView tv_btn_jixuyouxi;
    private ImageView iv_close;

    public OkDialog(Context context,String hint) {
        super(context);
        setCancelable(true);
        this.hint=hint;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       getWindow().setContentView(R.layout.dialog_ok);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        initView();
    }

    private void initView() {
        dialog_text = findViewById(R.id.dialog_text);
        dialog_text.setText(hint);
        tv_btn_jixuyouxi = findViewById(R.id.tv_btn_jixuyouxi);
        iv_close = findViewById(R.id.iv_close);
        iv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        tv_btn_jixuyouxi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    final Timer t = new Timer();
    @Override
    public void show() {
        super.show();
//        t.schedule(new TimerTask() {
//            public void run() {
//                if (this!=null&&isShowing()){
//                    dismiss();
//                }
//                if (t!=null){
//                    t.cancel();
//                }
//            }
//        }, 3000);
    }
}
